package com.gitee.wsl.common.ui.symbol

import androidx.compose.ui.graphics.Path
import com.gitee.wsl.common.ui.base.Point
import com.gitee.wsl.mathematics.geometry.shape.Arrow
import kotlin.math.cos
import kotlin.math.sin

fun Symbol.Companion.arrow(radius:Int, angle:Double, angleV:Double) = Arrow(radius, angle, angleV)


fun Path.arrow(x: Float, y: Float,arrow: Arrow) {
    /*mVelocityCalculator.calculate(x, y)
    val angleV = atan2(
        mVelocityCalculator.getVelocityY().toDouble(),
        mVelocityCalculator.getVelocityX().toDouble()
    )*/
    val delta: Double = arrow.angleV - arrow.angle
    val sum: Double = arrow.angleV + arrow.angle
    val rr: Double = arrow.radius / (2 * cos(arrow.angle))
    val x1 = (rr * cos(sum)).toFloat()
    val y1 = (rr * sin(sum)).toFloat()
    val x2 = (rr * cos(delta)).toFloat()
    val y2 = (rr * sin(delta)).toFloat()
    moveTo(x, y)
    lineTo(x - x1, y - y1)
    moveTo(x, y)
    lineTo(x - x2, y - y2)
}

fun Path.arrow(point: Point, arrow: Arrow) = arrow(point.x,point.y,arrow)